package com.atmk.atmk.designMode.创建型.工厂模式.工厂方法.反射;


import com.atmk.atmk.designMode.创建型.工厂模式.工厂方法.抽象产品.Phone;

public class PhoneFactory {
    public static Phone getInstance(String orgin) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        Class<?> cls  = Class.forName(orgin);  //Class.forName(传入完整的包类名)找到它的类，然后使用newInstance()方法反射的对象实例化
        Phone brand = (Phone)cls.newInstance();
        return brand;
    }
}
